-
Notifications
You must be signed in to change notification settings - Fork 87
Improve alignment in todo list output #576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
todoman/cli.py
Outdated
@@ -287,6 +290,17 @@ def formatter(self) -> formatters.Formatter: | |||
|
|||
@click.group(invoke_without_command=True) | |||
@click_log.simple_verbosity_option() | |||
@click.option( | |||
"--align", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
columns
is a more obvious name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
columns
is still a bit confusing, especially if we plan to support customizable column formats in the future. How about renaming it to column-aligned
?
8efbec1
to
05a1b2d
Compare
Thanks for your review and interest in this PR! I’ve fixed the issues you mentioned, except for the naming. I’d also like to add some tests. But it turns out the testing utility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this on my current set of tasks, and each line has a lot of trailing whitespace. This whitespace flows onto the next line, and as a result, there's an empty line after each todo.
Here's an example:
[ ] 722 (no due date) set up prometheuis @todo
[ ] 803 (no due date) set up xmpp metrics to prometheus @todo
Note all the empty spaces at the end of each line.
I think the issue is that ONE todo description is really long (not included in my copy-pasta), so all other are made equally long by appending spaces.
@WhyNotHugo Thanks for testing! I’ve skipped adding spaces after the last column if it is left-aligned. BTW, there are two spaces in your copy-paste because no priority was assigned to any of the todos. We could filter out these empty columns if you're interested. But it would change the current behavior, so I would prefer to handle it in a separate PR. |
Performance impact seems reasonable. I'm sure we can refine later if needed. Before:
After:
With 266 pending tasks and about 4k total files. |
|
||
summary = f"{todo.summary} {self.format_database(todo.list)}{percent}" | ||
|
||
# TODO: add spaces on the left based on max todos" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, I don't modify them. I think it's invalid now?
https://github.com/pimutils/todoman/blob/main/todoman%2Fformatters.py#L158
Problem
The current task list output is not column-aligned, which makes it hard to visually scan — especially with variable-width fields like task ID, priority, and date/time. This becomes more noticeable with long or complex lists.
What’s implemented
I've put together a working prototype that aligns the key fields (ID, priority, date/time) for better readability.
The new implementation refactors the original rendering logic into three clear steps: format, optional align, and style, based on a column configuration. Each column defines how its value is formatted, optionally aligned, and styled. This design makes the output easier to manage and extend.
It’s also future-proof: we can easily support custom output formats (e.g. via a user-defined column template string) without changing the rendering pipeline.
Examples
Next steps
If there's interest in this improvement, I’m happy to continue with the remaining parts — including tests, documentation, and polish.
close #575